<?php

/**
 * Ignus Framework
 *
 * @author Sergey Palyanov <sergey.palyanov@gmail.com>
 * @link http://code.google.com/p/ignus-php/
 * @license http://apache.org/licenses/LICENSE-2.0
 * @package Ignus
 * @subpackage Db
 * @since 0.3
 */

namespace Ignus\Db;

/**
 * @package Ignus
 * @subpackage Db
 * @since 0.3
 */
interface Driver
{
    /**
     * @abstract
     * @param string $dsn Connection string
     * @param array $options Connection options
     * @return object Connection object
     * @throws RuntimeException on connection failure
     */
    public function connect($dsn, array $options);

    /**
     * Returns entity data for specified identifier
     * @abstract
     * @param string $collection Table or collection of entities
     * @param mixed $id Entity identifier
     * @return array|null
     */
    public function getById($collection, $id);

    /**
     * Returns Query object to query data from collection
     * @param string $collectionName Collection name
     * @param array $query Query
     * @return Query
     */
    public function find($collectionName, array $query = array());

    /**
     * Generate next unique entity identifier
     * @abstract
     * @param string $collection Table or collection of entities
     * @return mixed
     * @since 0.5.4
     */
    public function generateId($collection);
}
